/*
 * @# ConfigReader.java 2011-6-16 下午03:21:04
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司
 * Guangzhou ianswer information technology co. ltd.
 * 
 * All rights reserved!
 */
package com.ianswer.px.utils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.apache.commons.lang.StringUtils;

import com.ianswer.common.util.PropertiesUtils;

/**
 * @author xulun
 */
public final class ConfigReader {
	private static Map<String, ConfigReader> configReaders = new HashMap<String, ConfigReader>();

	private Properties prop = null;

	private ConfigReader(String url) throws IOException {
		prop = PropertiesUtils.loadProperties(url);
	}

	public static ConfigReader getInstance(String url) throws IOException {
		ConfigReader configReader = configReaders.get(url);
		if (configReader == null) {
			configReader = new ConfigReader(url);
			configReaders.put(url, configReader);
		}
		return configReader;
	}

	public String getContent(String key) throws Exception {
		return prop == null ? StringUtils.EMPTY : prop.getProperty(key);
	}
}
